package com.sgb.kjwl.view.ui.fragment.manage;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.databinding.DataBindingUtil;
import androidx.fragment.app.Fragment;

import com.sgb.kjwl.AppFragment;
import com.sgb.kjwl.R;
import com.sgb.kjwl.databinding.ActivityIntellPropBinding;
import com.sgb.kjwl.databinding.FragmentShopCompanyPropertyBinding;
import com.sgb.kjwl.view.ui.activity.enterprise.IntellPropAcitivity;
import com.sgb.kjwl.view.ui.fragment.enterprise.IntellpropFragment;
import com.swgk.core.recyclerview.adapter.SlidingFragmentPagerAdapter;

import java.util.ArrayList;

public class IntellectualPropertyRightMainFragment extends AppFragment {
    private FragmentShopCompanyPropertyBinding binding;

    private ArrayList<Fragment> mFragments;
    private String[] titles = {"商标", "专利", "版权"};
    private String companyNo;

    public static IntellectualPropertyRightMainFragment newInstance(String companyNo) {
        IntellectualPropertyRightMainFragment fragment = new IntellectualPropertyRightMainFragment();
        Bundle bundle = new Bundle();
        bundle.putString("companyNo", companyNo);
        fragment.setArguments(bundle);
        return fragment;
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        binding = DataBindingUtil.inflate(inflater,R.layout.fragment_shop_company_property,container,false);
        binding.tlShopCompanyManage.setBackgroundResource(R.color.white);
        mFragments = new ArrayList<>();
        companyNo = getArguments().getString("companyNo");
        showTypeView();
        return binding.getRoot();
    }

    public void showTypeView() {
        for (int i = 0; i < titles.length; i++) {
            mFragments.add(IntellectualPropertyRightFragment.newInstance(i,companyNo));
        }
        SlidingFragmentPagerAdapter pagerAdapter = new SlidingFragmentPagerAdapter(getChildFragmentManager(), mFragments, titles);
        binding.vpShopCompanyManage.setOffscreenPageLimit(titles.length);
        binding.vpShopCompanyManage.setAdapter(pagerAdapter);
        binding.tlShopCompanyManage.setupWithViewPager(binding.vpShopCompanyManage);
    }

    public void changeType(int position) {
        binding.vpShopCompanyManage.setCurrentItem(position);
    }
}